package dk.mitaffald.main;

import com.androidhive.jsonparsing.R;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;


public class Location_Finder extends Activity {

public TextView LongCoord;
public TextView LatCoord;
public double longitude;
public double latitude;
public LocationManager lm;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hidden_btns);
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, new MyLocationListener());

    LongCoord = (TextView)findViewById(R.id.lng);
    LatCoord = (TextView)findViewById(R.id.lat);

    showCurrentLocation();
}


protected void showCurrentLocation() 
{
    // TODO Auto-generated method stub
    Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    latitude = location.getLatitude();
    longitude = location.getLongitude();

    LongCoord.setText(Double.toString(longitude));
    LatCoord.setText(Double.toString(latitude));
    
    Toast.makeText(getApplicationContext(), 
            "this is " +LatCoord + "" +LongCoord, Toast.LENGTH_LONG).show();
}

}

class MyLocationListener implements LocationListener
{

	@Override
	public void onLocationChanged(Location location) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
		
	}

}